﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using la.P2KServer;

namespace la.P2KServer
{
    public class P2KServerDataProvider : P2KServerBase
    {
        public string SQLServer                                             
        {
            set { SetValue(SQLServerProperty, value); }
            get { return (string)GetValue(SQLServerProperty); }
        }
        public string DataBaseName                                          
        {
            set { SetValue(DataBaseNameProperty, value); }
            get { return (string)GetValue(DataBaseNameProperty); }
        }
        public string DBUserName                                            
        {
            set { SetValue(DBUserNameProperty, value); }
            get { return (string)GetValue(DBUserNameProperty); }
        }
        public string DBPassword                                            
        {
            set { SetValue(DBPasswordProperty, value); }
            get { return (string)GetValue(DBPasswordProperty); }
        }
       
        public static readonly DependencyProperty SQLServerProperty;
        public static readonly DependencyProperty DataBaseNameProperty;
        public static readonly DependencyProperty DBUserNameProperty;
        public static readonly DependencyProperty DBPasswordProperty;

        public static string GetSQLServer(UIElement element)                
        {
            if (element == null) throw new ArgumentException("");
            return (string)element.GetValue(P2KServerDataProvider.SQLServerProperty);
        }
        public static void SetSQLServer(UIElement element, string value)    
        {
            if (element == null) throw new ArgumentException("");
            element.SetValue(P2KServerDataProvider.SQLServerProperty,value);
        }
        
        public static string GetDataBaseName(UIElement element)             
        {
            if (element == null) throw new ArgumentException("");
            return (string)element.GetValue(P2KServerDataProvider.DataBaseNameProperty);
        }
        public static void SetDataBaseName(UIElement element, string value) 
        {
            if (element == null) throw new ArgumentException("");
            element.SetValue(P2KServerDataProvider.DataBaseNameProperty, value);
        }
        
        public static string GetUserName(UIElement element)                 
        {
            if (element == null) throw new ArgumentException("");
            return (string)element.GetValue(P2KServerDataProvider.DBUserNameProperty);
        }
        public static void SeUserName(UIElement element, string value)      
        {
            if (element == null) throw new ArgumentException("");
            element.SetValue(P2KServerDataProvider.DBUserNameProperty, value);
        }
        
        public static string GetPassword(UIElement element)                 
        {
            if (element == null) throw new ArgumentException("");
            return (string)element.GetValue(P2KServerDataProvider.DBPasswordProperty);
        }
        public static void SePassword(UIElement element, string value)      
        {
            if (element == null) throw new ArgumentException("");
            element.SetValue(P2KServerDataProvider.DBPasswordProperty, value);
        }

        static P2KServerDataProvider()
        {
            
            FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.None);            
            SQLServerProperty = DependencyProperty.RegisterAttached("SQLServer", typeof(string), typeof(FrameworkElement), metadata);
            metadata = new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.None);
            DBUserNameProperty = DependencyProperty.RegisterAttached("UserName", typeof(string), typeof(FrameworkElement), metadata);
            metadata = new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.None);
            DataBaseNameProperty = DependencyProperty.RegisterAttached("DataBaseName", typeof(string), typeof(FrameworkElement), metadata);           
            metadata = new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.None);
            DBPasswordProperty = DependencyProperty.RegisterAttached("Password", typeof(string), typeof(FrameworkElement), metadata);                                  
        }

        public void getValueOnDataBase()
        {

        }

    }
}
